/**
 * Created by frank on 2016/8/30.
 */
(function () {
    'use strict';

    angular
        .module('movements.controller', [])
        .controller('MovementsCtrl', MovementsCtrl);

    MovementsCtrl.$inject = ['$scope','$yikeUtils','$state','$ionicHistory','$ionicTabsDelegate','$timeout','localStorageService','$ionicLoading','$ionicScrollDelegate','$ionicPopup','$rootScope'];
    /* @ngInject */
    function MovementsCtrl($scope,$yikeUtils,$state,$ionicHistory,$ionicTabsDelegate,$timeout,localStorageService,$ionicLoading,$ionicScrollDelegate,$ionicPopup,$rootScope){
        var user=localStorageService.get('user');
        $scope.goBuyRights1 = goBuyRights1;
        $scope.arrayItem = [
            {img:"img/movements/1.png",title:"冠军分析",detail:"冠军冷热遗漏分析",ob:'first',content:'冠军'},
            {img:"img/movements/2.png",title:"亚军分析",detail:"亚军冷热遗漏分析",ob:'second',content:'亚军'},
            {img:"img/movements/3.png",title:"季军分析",detail:"季军冷热遗漏分析",ob:'third',content:'季军'},
            {img:"img/movements/4.png",title:"第4名分析",detail:"第4名冷热遗漏分析",ob:'fourth',content:'第四'},
            {img:"img/movements/5.png",title:"第5名分析",detail:"第5名冷热遗漏分析",ob:'fifth',content:'第五'},
            {img:"img/movements/6.png",title:"第6名分析",detail:"第6名冷热遗漏分析",ob:'sixth',content:'第六'},
            {img:"img/movements/7.png",title:"第7名分析",detail:"第7名冷热遗漏分析",ob:'seventh',content:'第七'},
            {img:"img/movements/8.png",title:"第8名分析",detail:"第8名冷热遗漏分析",ob:'eighth',content:'第八'},
            {img:"img/movements/9.png",title:"第9名分析",detail:"第9名冷热遗漏分析",ob:'ninth',content:'第九'},
            {img:"img/movements/10.png",title:"第10名分析",detail:"第10名遗漏分析",ob:'tenth',content:'第十'}
        ];
        init();
        function init() {
            /*$ionicTabsDelegate.showBar(false);//隐藏开奖走势导航栏*/
            $ionicLoading.show({
                template: '<ion-spinner icon="bubbles"></ion-spinner>'
            });
            yikeTaishan.expire(user.id,user.token)
                .then(function (data) {
                    if(data.status == 1){
                        $ionicLoading.hide();
                    }else{
                        var alertPopup = $ionicPopup.alert({
                            title: '提示',
                            template: data.result.result,
                            buttons:[{
                                text:'确定',
                                type: 'button-positive'
                            }]
                        });
                        alertPopup.then(function() {
                            $ionicLoading.hide();
                            localStorageService.remove('user');
                            $state.go('login')
                        });
                    }
                })
        }
        //购买授权
        function goBuyRights1(){
            $rootScope.buytype = 1;
            $state.go('pay-rights');
        }
    }
})();
